package cn.name168.ssm.controller;

import cn.name168.ssm.entity.User;
import cn.name168.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by Nominal on 2018/4/5 0005.
 * 微博：@Mr丶Li_Anonym
 */
@Controller//控制器注解
public class UserController {
    //自动注入
    @Autowired
    UserService userService;
    @RequestMapping(value = "to_show/{id}",method = RequestMethod.GET)//访问地址注解
    public String toShow(Model model, @PathVariable Integer id){
        User user=userService.findUserById(id);
        model.addAttribute("users",user);
        return "show";
    }
}
